<?php echo $header;echo $sidebar ?>		

	<style>
		select {background-color: #FFFFFF;border: 1px solid #CCCCCC;width: 100% !important;}
		.clear{clear: both;}
		.row:before, .row:after {
    content: " ";
    display: table;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:after {
    clear: both;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:after {
    clear: both;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:after {
    clear: both;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:after {
    clear: both;
}
.row:before, .row:after {
    content: " ";
    display: table;
}
.row:after {
    clear: both;
}
.row:before, .row:after {
    content: " ";
    display: table;
}

.col-lg-1 {
    margin-bottom: 10px;
    width: 15%;
}
.col-lg-1 {
    width: 8.33333%;
}
.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11 {
    float: left;
}
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
    min-height: 1px;
    padding-left: 15px;
    padding-right: 15px;
    position: relative;
}
	</style>
	
	<div class="span10 content">

		<?php echo $hugemenu ?>

		<?php if($this->session->flashdata('message')) :?>
			<div class="alert alert-success">
				<?php echo $this->session->flashdata('message') ?>
			</div>
		<?php endif; ?>
		
		<?php #if($message) { echo "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $message . "</div>"; } ?>

		<div class="col-lg-12">
		<?php 
        $error = $this->session->flashdata('error');
            	
        if($error)
        {
        	echo "<div class='alert alert-danger'>{$error}</div>";
        } ?>
        
        <h3><?php echo substr($ticket[0]['tickets_title'], 0, 29); if(strlen($ticket[0]['tickets_title']) > 29) { echo "..."; } ?> 
        	<span class="pull-right visible-lg">
        		<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#edit-ticket">Edit</button> 
        		<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#new-note">Note</button> 
        		<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#new-attachment">Attach</button> 
        		<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#new-association">Associate</button>
        		
        		<?php 
				if($this->session->userdata('level'))
				{ ?>
					<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#delete-ticket">Delete</button> 
				<?php 
				} ?>
        	</span>
        </h3>
		<hr>
		
		<div class="modal fade" id="edit-ticket" tabindex="-1" role="dialog" aria-labelledby="edit-ticket-label" aria-hidden="true">
	    	<div class="modal-dialog">
	      		<div class="modal-content">
	        		<div class="modal-header">
	          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	          			<h4 class="modal-title">Edit Ticket</h4>
	        		</div>
	        		<div class="modal-body">
	        			<form id="edit-ticket-form" action="<?php echo base_url(); ?>tickets/update/<?php echo $ticket[0]['tickets_id']; ?>" method="post">
	        				<div class="form-group">
	        					<label>Title *</label>
	        					<input name="title" type="text" class="form-control" value="<?php echo $ticket[0]['tickets_title']; ?>" autocomplete="off">
	        				</div>
	        				
	        				<div class="form-group">
	        					<label>Assigned To *</label>
	        					<select name="assigned[]" multiple class="form-control">
							    	<?php
							    	for($i = 0; $i < count($users); ++$i)
							    	{
							    		for($j = 0; $j < count($assigned); ++$j)
							    		{
							    			if($users[$i]['id'] == $assigned[$j]['assigned_user_id'])
							    			{ ?>
							    				<option value="<?php echo $users[$i]['id']; ?>" selected="selected"><?php echo $users[$i]['first_name'].' '.$users[$i]['last_name']; ?></option>
							    				<?php $users[$i] = NULL; ?>
							    			<?php
							    			} ?>
							    		<?php
							    		} ?>
							    	<?php
							    	} ?>

							    	<?php
									$users = array_values($users);

									for($i = 0; $i < count($users); ++$i)
									{
										if($users[$i] != NULL)
										{ ?>
												<option value="<?php echo $users[$i]['id']; ?>"><?php echo $users[$i]['first_name'].' '.$users[$i]['last_name']; ?></option>
										<?php
										}
									} ?>
						    	</select>
	        				</div>
	        				
	        				<div class="form-group">
	        					<label>Severity *</label>
	        					<select name="severity" class="form-control">
					        		<?php
									$critical = null;
									$high = null;
									$medium = null;
									$low = null;

									if($ticket[0]['tickets_severity_description'] == 'Critical')
									{
										$critical = "selected='selected'";
									}
									elseif($ticket[0]['tickets_severity_description'] == 'High')
									{
										$high = "selected='selected'";
									}
									elseif($ticket[0]['tickets_severity_description'] == 'Medium')
									{
										$medium = "selected='selected'";
									}
									elseif($ticket[0]['tickets_severity_description'] == 'Low')
									{
										$low = "selected='selected'";
									} ?>

							      	<option <?php echo $critical; ?> value="104">Critical</option>
							      	<option <?php echo $high; ?> value="105">High</option>
							      	<option <?php echo $medium; ?> value="106">Medium</option>
							      	<option <?php echo $low; ?> value="107">Low</option>
						      	</select>
	        				</div>
	        				
	        				<div class="form-group">
	        					<label>Status *</label>
	        					<select name="status" class="form-control">
					        		<?php
									$open = null;
									$development = null;
									$testing = null;
									$closed = null;
									$hold = null;

									if($ticket[0]['tickets_status_description'] == 'Open')
									{
										$open = "selected='selected'";
									}
									elseif($ticket[0]['tickets_status_description'] == 'Development')
									{
										$development = "selected='selected'";
									}
									elseif($ticket[0]['tickets_status_description'] == 'Testing')
									{
										$testing = "selected='selected'";
									}
									elseif($ticket[0]['tickets_status_description'] == 'Closed')
									{
										$closed = "selected='selected'";
									}
									elseif($ticket[0]['tickets_status_description'] == 'On Hold')
									{
										$hold = "selected='selected'";
									} ?>

							      	<option <?php echo $open; ?> value="100">Open</option>
							      	<option <?php echo $development; ?> value="101">Development</option>
							      	<option <?php echo $testing; ?> value="102">Testing</option>
							      	<option <?php echo $hold; ?> value="108">On Hold</option>
							      	<option <?php echo $closed; ?> value="103">Closed</option>
						      	</select>
	        				</div>
	        				
	        				<div class="form-group">
				        		<label>Department *</label>
				        		<select name="department" class="form-control">
				        			<?php
									for($i = 0; $i < count($departments); ++$i)
									{
										if($departments[$i]['department_id'] == $ticket[0]['department_id'])
										{ ?>
											<option value="<?php echo $departments[$i]['department_id']; ?>" selected="selected"><?php echo $departments[$i]['department_name']; ?></option>
										<?php
										}
										else
										{ ?>
											<option value="<?php echo $departments[$i]['department_id']; ?>"><?php echo $departments[$i]['department_name']; ?></option>
										<?php
										}
									} ?>
						      	</select>
				        	</div>
				        	
	        				<div class="form-group">
				        		<label>Project *</label>
				        		<select name="project" class="form-control">
							      	<?php
									for($i = 0; $i < count($projects); ++$i)
									{
										if($projects[$i]['project_id'] == $ticket[0]['project_id'])
										{ ?>
											<option value="<?php echo $projects[$i]['project_id']; ?>" selected="selected"><?php echo $projects[$i]['project_name']; ?></option>
										<?php
										}
										else
										{ ?>
											<option value="<?php echo $projects[$i]['project_id']; ?>"><?php echo $projects[$i]['project_name']; ?></option>
										<?php
										}
									} ?>
						      	</select>
				        	</div>
				        	
	        				<div class="form-group">
				        		<label>Process *</label>
					        	<select name="process" class="form-control">
							      	<?php
									for($i = 0; $i < count($processes); ++$i)
									{
										if($processes[$i]['process_id'] == $ticket[0]['process_id'])
										{ ?>
											<option value="<?php echo $processes[$i]['process_id']; ?>" selected="selected"><?php echo $processes[$i]['process_name']; ?></option>
										<?php
										}
										else
										{ ?>
											<option value="<?php echo $processes[$i]['process_id']; ?>"><?php echo $processes[$i]['process_name']; ?></option>
										<?php
										}
									} ?>
						      	</select>
						    </div>
	        				
	        				<div class="form-group">
				        		<label>Due By *</label>
				        		<input name="completion" type="text" class="form-control datepicker" value="<?php echo date("m/d/Y", strtotime($ticket[0]['tickets_desired_completion'])); ?>" data-date-format="mm/dd/yy">
				        	</div>
				        	
	        				<div class="form-group">
				                <label>Hours Allotted</label>
	        					<input name="hours_allotted" type="text" class="form-control" autocomplete="off" value="<?php echo $ticket[0]['tickets_hours_allotted']; ?>">
				            </div>
	        				
	        				<div class="form-group">
		        				<label>Hours Worked</label>
		        				<input name="hours_worked" type="text" class="form-control" autocomplete="off" value="<?php echo $ticket[0]['tickets_hours_completed']; ?>">
	        				</div>
	        				
	        				<div class="form-group">
		        				<label>Description of Issue</label>
		        				<textarea name="description" class="form-control" rows="8"><?php echo $ticket[0]['tickets_description']; ?></textarea>
	        				</div>
	        			</form>
	        		</div>
	        		<div class="modal-footer">
	          			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	          			<button type="button" class="btn btn-primary" onclick="document.getElementById('edit-ticket-form').submit();">Update</button>
	        		</div>
	      		</div>
	    	</div>
	  	</div>
		
		<div class="modal fade" id="new-note" tabindex="-1" role="dialog" aria-labelledby="new-note-label" aria-hidden="true">
	    	<div class="modal-dialog">
	      		<div class="modal-content">
	        		<div class="modal-header">
	          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	          			<h4 class="modal-title">Create New Note</h4>
	        		</div>
	        		<div class="modal-body">
	        			<form id="new-note-form" action="<?php echo base_url(); ?>tickets/note/<?php echo $ticket[0]['tickets_id']; ?>" method="post">
	          				<textarea name="note" class="form-control" rows="8" placeholder="Type in your note..."></textarea>
	        			</form>
	        		</div>
	        		<div class="modal-footer">
	          			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	          			<button type="button" class="btn btn-primary" onclick="document.getElementById('new-note-form').submit();">Create Note</button>
	        		</div>
	      		</div>
	    	</div>
	  	</div>
	  	
	  	<div class="modal fade" id="new-attachment" tabindex="-1" role="dialog" aria-labelledby="new-attachment-label" aria-hidden="true">
	    	<div class="modal-dialog">
	      		<div class="modal-content">
	        		<div class="modal-header">
	          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	          			<h4 class="modal-title">Add New Attachment</h4>
	        		</div>
	        		<div class="modal-body">
	        			<form id="new-attachment-form" action="<?php echo base_url(); ?>tickets/upload/<?php echo $ticket[0]['tickets_id']; ?>/<?php echo $ticket[0]['department_id']; ?>/<?php echo $ticket[0]['project_id']; ?>" enctype="multipart/form-data" method="post">
	          				<input type="file" name="file">
	          				<br>
	          				<textarea name="description" class="form-control" rows="8" placeholder="Description about the file you are attaching..."></textarea>
	        			</form>
	        		</div>
	        		<div class="modal-footer">
	          			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	          			<button type="button" class="btn btn-primary" onclick="document.getElementById('new-attachment-form').submit();">Add Attachment</button>
	        		</div>
	      		</div>
	    	</div>
	  	</div>
	  	
	  	<?php 
		if($this->session->userdata('level'))
		{ ?>
		  	<div class="modal fade" id="delete-ticket" tabindex="-1" role="dialog" aria-labelledby="delete-ticket-label" aria-hidden="true">
		    	<div class="modal-dialog">
		      		<div class="modal-content">
		        		<div class="modal-header">
		          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		          			<h4 class="modal-title">Delete Ticket</h4>
		        		</div>
		        		<div class="modal-body">
		          			Are you sure you want to permanently delete this ticket?
		        		</div>
		        		<div class="modal-footer">
		          			<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
		          			<a href="<?php echo base_url(); ?>tickets/delete/<?php echo $ticket[0]['tickets_id']; ?>"><button type="button" class="btn btn-primary">Yes</button></a>
		        		</div>
		      		</div>
		    	</div>
		  	</div>
		<?php 
		} ?>
	  	
	  	<div class="modal fade" id="new-association" tabindex="-1" role="dialog" aria-labelledby="new-association-label" aria-hidden="true">
	    	<div class="modal-dialog">
	      		<div class="modal-content">
	        		<div class="modal-header">
	          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	          			<h4 class="modal-title">Associate Two Tickets Together</h4>
	        		</div>
	        		<div class="modal-body">
	        			<form id="new-association-form" action="<?php echo base_url(); ?>tickets/associate/<?php echo $ticket[0]['tickets_id']; ?>" method="post">
	          				<input name="associated_ticket" type="text" class="form-control" placeholder="A valid ticket that belongs to your company..." autocomplete="off">
	        			</form>
	        		</div>
	        		<div class="modal-footer">
	          			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	          			<button type="button" class="btn btn-primary" onclick="document.getElementById('new-association-form').submit();">Associate</button>
	        		</div>
	      		</div>
	    	</div>
	  	</div>
		
		<ul class="nav nav-tabs" style="margin-bottom:15px;">
			<li class="active"><a href="#summary" data-toggle="tab">Summary</a></li>
            <li class=""><a href="#notes" data-toggle="tab">Notes (<?php if($notes) echo count($notes); else echo "0"; ?>)</a></li>
          	<li class="visible-lg"><a href="#attachments" data-toggle="tab">Attachments (<?php if($attachments) echo count($attachments); else echo "0"; ?>)</a></li>
          	<li class="visible-lg"><a href="#history" data-toggle="tab">History (<?php if($history) echo count($history); else echo "0"; ?>)</a></li>
          	<li class="visible-lg"><a href="#associated" data-toggle="tab">Associated (<?php if($associated) echo count($associated); else echo "0"; ?>)</a></li>
		</ul>
             
		<div class="tab-content">
			<div class="tab-pane active in" id="summary">
				<div class="row">
					<div class="col-lg-1"><strong>Title:</strong></div>
					<div class="col-lg-11"><?php echo $ticket[0]['tickets_title']; ?></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Logged:</strong></div>
					<div class="col-lg-11"><a href="<?php echo base_url(); ?>index.php/users/view/<?php echo $ticket[0]['logged_user_id']; ?>"><?php echo $ticket[0]['first_name'].' '.$ticket[0]['last_name']; ?></a></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Assigned:</strong></div>
					<div class="col-lg-11"> 
					<?php 
        			for($i = 0; $i < count($assigned); ++$i)
        			{ 
        				echo "<a href='".base_url()."index.php/admin/userEditgroup/".$assigned[$i]['assigned_user_id']."'>".$assigned[$i]['assigned_user_first_name'].' '.$assigned[$i]['assigned_user_last_name']."</a>";
        				
        				if($i != count($assigned) - 1)
        					echo ", ";
        			} ?>
					</div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Severity:</strong></div>
					<div class="col-lg-11"><?php echo $ticket[0]['tickets_severity_description']; ?></div>
				</div>
				
				<div class="row">	
					<div class="col-lg-1"><strong>Status:</strong></div>
					<div class="col-lg-11"><?php echo $ticket[0]['tickets_status_description']; ?></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Dept:</strong></div>
					<div class="col-lg-11"><a href="<?php echo base_url(); ?>index.php/departments/view/<?php echo $ticket[0]['department_id']; ?>"><?php echo $ticket[0]['department_name']; ?></a></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Project:</strong></div>
					<div class="col-lg-11"><a href="<?php echo base_url(); ?>index.php/projects/view/<?php echo $ticket[0]['project_id']; ?>"><?php echo $ticket[0]['project_name']; ?></a></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Process:</strong></div>
					<div class="col-lg-11"><a href="<?php echo base_url(); ?>index.php/processes/view/<?php echo $ticket[0]['process_id']; ?>"><?php echo $ticket[0]['process_name']; ?></a></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Logged:</strong></div>
					<div class="col-lg-11"><?php echo date("m/d/Y", strtotime($ticket[0]['tickets_logged_on'])); ?></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Due:</strong></div>
					<div class="col-lg-11"><?php echo date("m/d/Y", strtotime($ticket[0]['tickets_desired_completion'])); ?></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Allotted:</strong></div>
					<div class="col-lg-11"><?php echo $ticket[0]['tickets_hours_allotted']; ?></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>Completed:</strong></div>
					<div class="col-lg-11"><?php echo $ticket[0]['tickets_hours_completed']; ?></div>
				</div>
				
				<div class="row">
					<div class="col-lg-1"><strong>About:</strong></div>
					<div class="col-lg-11"><?php echo nl2br($ticket[0]['tickets_description']); ?></div>
				</div>
            </div>
                
			<div class="tab-pane" id="notes">
				<div class="row">
					<div class="col-lg-12">
						<?php
						if($notes)
						{ 
							for($i = 0; $i < count($notes); ++$i)
							{ ?>
								<p>
									<a href="<?php echo base_url(); ?>index.php/admin/userEditgroup/<?php echo $notes[$i]['user_id']; ?>"><?php echo $notes[$i]['user_first_name'].' '.$notes[$i]['user_last_name']; ?></a> - <?php echo date("m/d/Y", strtotime($notes[$i]['tickets_notes_posted_date'])); ?>
									<br />
									<?php echo nl2br($notes[$i]['tickets_notes_note']); ?>
									
									<?php 
									if($i < count($notes) - 1) 
									{ ?>
										<hr>
									<?php 
									} ?>
								</p>
							<?php 
							} 
						} 
						else
						{ ?>
							<p>This ticket does not have any notes.</p>
						<?php
						} ?>
					</div>
				</div>
			</div>
                
			<div class="tab-pane" id="attachments">
                <div class="row">
                	<div class="col-lg-12">
                		<?php
		        		if($attachments)
		        		{ ?>
			        		<table class="table table-striped table-bordered table-hover datatables">
								<thead>
							    	<tr>
									    <th>Link</th>
									    <th>Uploaded By</th>
									    <th>Description</th>
									    <th>Comments</th>
									    <th>Action</th>
							    	</tr>
							  	</thead>
							  	<tbody>
							  		<?php
							  		for($i = 0; $i < count($attachments); ++$i)
							  		{ ?>
								    	<tr>
									    	<td><a href="<?php echo base_url().'assets/uploads/tickets/'.$attachments[$i]['tickets_file_hash_name']; ?>" target="_blank"><?php echo $attachments[$i]['tickets_file_real_name']; ?></a></td>
									      	<td><a href="<?php echo base_url(); ?>index.php/users/view/<?php echo $attachments[$i]['user_id']; ?>"><?php echo $attachments[$i]['user_first_name'].' '.$attachments[$i]['user_last_name']; ?></a></td>
									      	<td><a href="javascript:;" data-toggle="modal" data-target="#file-description-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>">Show</a></td>
									      	<td><a href="javascript:;" data-toggle="modal" data-target="#file-view-comments-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>">Show (<?php if(count($file_comments[$i]) > 0) echo count($file_comments[$i]); else echo "0"; ?>)</a></td>
									      	<td class="text-center">
									      		<a style="color:#e74c3c;margin-right:5px;" href="<?php echo base_url(); ?>index.php/tickets/remove/<?php echo $ticket[0]['tickets_id']; ?>/<?php echo $attachments[$i]['tickets_file_id']; ?>"><i class="icon-remove"></i></a>
									      		<a style="color:#3498db;" href="javascript:;" data-toggle="modal" data-target="#file-create-comment-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>"><i class="icon-pencil"></i></a>
									      	</td>
								    	</tr>
								    <?php
							  		} ?>
							    </tbody>
							</table>
						<?php
		        		}
		        		else
		        		{ ?>
		        			<p>This ticket does not have any attached files.</p>
		        		<?php
		        		} ?>
                	</div>
                </div>
			</div>
			
			<?php
        	if($attachments)
        	{ 
		  		for($i = 0; $i < count($attachments); ++$i)
		  		{ ?>
					<div class="modal fade" id="file-description-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>" tabindex="-1" role="dialog" aria-labelledby="file-description-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>" aria-hidden="true">
				    	<div class="modal-dialog">
				      		<div class="modal-content">
				        		<div class="modal-header">
				          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				          			<h4 class="modal-title">File Description</h4>
				        		</div>
				        		<div class="modal-body">
				        			<?php echo nl2br($attachments[$i]['tickets_file_description']); ?>
				        		</div>
				        		<div class="modal-footer">
				          			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				        		</div>
				      		</div>
				    	</div>
				  	</div>
				  	
				  	<div class="modal fade" id="file-view-comments-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>" tabindex="-1" role="dialog" aria-labelledby="file-description-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>" aria-hidden="true">
				    	<div class="modal-dialog">
				      		<div class="modal-content">
				        		<div class="modal-header">
				          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				          			<h4 class="modal-title">File Comments</h4>
				        		</div>
				        		<div class="modal-body">
				        			<?php 
				        			if(count($file_comments[$i]) > 0)
				        			{
					        			for($j = 0; $j < count($file_comments[$i]); ++$j)
					        			{ ?>
					        				<p><a href="<?php echo base_url(); ?>index.php/admin/userEditgroup/<?php echo $file_comments[$i][$j]['user_id']; ?>"><?php echo $file_comments[$i][$j]['user_first_name'].' '.$file_comments[$i][$j]['user_last_name']; ?></a></p>
					        				<p><?php echo nl2br($file_comments[$i][$j]['tickets_files_comments_description']); ?></p>
					        				<?php 
					        				if($j != count($file_comments[$i]) - 1)
					        				{ ?>
					        					<hr>
					        				<?php 
					        				} 
				  						}
				  					} 
				  					else
				  					{ ?>
				  						This file has no comments.
				  					<?php 
					        		} ?>
				        		</div>
				        		<div class="modal-footer">
				          			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				        		</div>
				      		</div>
				    	</div>
				  	</div>
				  	
				  	<div class="modal fade" id="file-create-comment-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>" tabindex="-1" role="dialog" aria-labelledby="file-description-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>" aria-hidden="true">
				    	<div class="modal-dialog">
				      		<div class="modal-content">
				        		<div class="modal-header">
				          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				          			<h4 class="modal-title">Create Comment</h4>
				        		</div>
				        		<div class="modal-body">
				        			<form id="new-file-comment-form-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>" action="<?php echo base_url(); ?>tickets/comment/<?php echo $ticket[0]['tickets_id']; ?>/<?php echo $attachments[$i]['tickets_file_id']; ?>" method="post">
				          				<textarea name="comment" class="form-control" rows="8" placeholder="Type in your comment..."></textarea>
				        			</form>
				        		</div>
				        		<div class="modal-footer">
				          			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				          			<button type="button" class="btn btn-primary" onclick="document.getElementById('new-file-comment-form-<?php echo $ticket[0]['tickets_id']; ?>-<?php echo $attachments[$i]['tickets_file_id']; ?>').submit();">Create Comment</button>
				        		</div>
				      		</div>
				    	</div>
				  	</div>
				<?php 
		  		} 
        	} ?>
			
			<div class="tab-pane" id="history">
                <div class="row">
                	<div class="col-lg-12">
                		<?php
		        		if($history)
		        		{ ?>
			        		<table class="table table-striped table-bordered table-hover">
								<thead>
							    	<tr>
									    <th>Who?</th>
									    <th>What?</th>
									    <th>When?</th>
							    	</tr>
							  	</thead>
							  	<tbody>
							  		<?php
							  		for($i = 0; $i < count($history); ++$i)
							  		{ ?>
								    	<tr>
									    	<td><a href="<?php echo base_url(); ?>index.php/admin/userEditgroup/<?php echo $history[$i]['user_id']; ?>"><?php echo $history[$i]['user_first_name'].' '.$history[$i]['user_last_name']; ?></a></td>
									      	<td><?php echo $history[$i]['history_description']; ?></td>
									      	<td><?php echo date("m/d/Y", strtotime($history[$i]['tickets_history_timestamp'])); ?></td>
								    	</tr>
								    <?php
							  		} ?>
							    </tbody>
							</table>
						<?php
		        		}
		        		else
		        		{ ?>
		        			<p>This ticket does not have any history.</p>
		        		<?php
		        		} ?>
                	</div>
                </div>
			</div>
			
			<div class="tab-pane" id="associated">
                <div class="row">
                	<div class="col-lg-12">
                		<?php
		        		if($associated)
		        		{ ?>
			        		<table class="table table-striped table-bordered table-hover">
								<thead>
							    	<tr>
									    <th>Title<span class="sort-icon"><span></th>
							    	</tr>
							  	</thead>
							  	<tbody>
							  		<?php
							  		for($i = 0; $i < count($associated); ++$i)
							  		{ ?>
								    	<tr>
									      	<td><a href="<?php echo base_url(); ?>index.php/tickets/view/<?php echo $associated[$i]['tickets_id']; ?>"><?php echo $associated[$i]['tickets_title']; ?></a></td>
								    	</tr>
								    <?php
							  		} ?>
							    </tbody>
							</table>
						<?php
		        		}
		        		else
		        		{ ?>
		        			<p>This ticket does not have any tickets associated with it.</p>
		        		<?php
		        		} ?>
                	</div>
                </div>
			</div>
		</div>
	</div>
		
		
	</div><!--/content-->

<?php echo $footer ?>